import App from "./App";
import Vue from "vue";
import "./uni.promisify.adaptor";
import { createPinia } from "pinia";
import { createSSRApp } from "vue";

Vue.config.productionTip = false;

App.mpType = "app";

// 引入全局 uView
import uView from "@/uni_modules/uview-ui";
Vue.use(uView);

// 全局存储 vuex 的封装
import store from "@/store";

// 引入 uView 提供的对 vuex 的简写法文件
let vuexStore = require("@/store/$u.mixin.js");
Vue.mixin(vuexStore);

// 引入 uView 对小程序分享的 mixin 封装
let mpShare = require("@/uni_modules/uview-ui/libs/mixin/mpShare.js");
Vue.mixin(mpShare);

// 注册全局组件
import bottomTabbar from '@/components/bottomTabbar/bottomTabbar.vue'
Vue.component('BottomTabbar', bottomTabbar);

const app = new Vue({
	store,
	...App
});

import { replaceAll } from "@/common/common.js";
Vue.prototype.replaceAll = replaceAll;

// http 接口 API 抽离，免于写 url 或者一些固定的参数
import httpApi from '@/common/http.api.js';
Vue.use(httpApi, app);

app.$mount();

export function createApp() {
	const app = createSSRApp(App);
	app.use(createPinia());
	return {
		app
	};
}
